# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=recode
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=3.7.15
pkgrel=1
pkgdesc="Converts files between various character sets and usages (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/rrthomas/recode"
license=('GPL3' 'LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-gettext-runtime")
makedepends=("${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-autotools"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-gettext-tools"
             "help2man")
source=("https://github.com/rrthomas/recode/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('f590407fc51badb351973fc1333ee33111f05ec83a8f954fd8cf0c5e30439806')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  export lt_cv_deplibs_check_method='pass_all'

  PYTHON="${MINGW_PREFIX}/bin/python3" \
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --mandir=${MINGW_PREFIX}/share/man \
    --infodir=${MINGW_PREFIX}/share/info \
    --without-libiconv-prefix \
    --without-libintl-prefix

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING-LIB" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING-LIB"
}
